package org.xg.study.pd.event;

import org.xg.study.pd.ICouponDiscount;

import java.math.BigDecimal;

/**
 * @author CMG
 * @version 1.0
 * @description
 * @cLassName ZJCouponDiscount
 * @date 2021/9/18 9:10
 **/
public class ZJCouponDiscount implements ICouponDiscount<Double> {
    /**
     * 直减计算
     *      * 1. 使用商品价格减去优惠价格
     *      * 2. 最低支付金额1元
     * @param couponInfo 折扣卷信息 ；直减、满减、折扣、N元购
     * @param skuPrice sku金额
     * @return
     */
    @Override
    public BigDecimal discountAmount(Double couponInfo, BigDecimal skuPrice) {
        BigDecimal discountAmount = skuPrice.subtract(new BigDecimal(couponInfo));
        if (discountAmount.compareTo(BigDecimal.ZERO) < 1) {
            return BigDecimal.ZERO;
        }
        return discountAmount;
    }
}
